package com.cpm.offcn.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.security.PublicKey;

public class RabbitUtils {
       private static   ConnectionFactory factory = new ConnectionFactory();
       static {
            factory.setHost("192.168.111.131");
            factory.setPort(5672);
            factory.setUsername("guest");
            factory.setPassword("guest");
            factory.setVirtualHost("/");//默认虚拟机

    }
    //获取TCP长连接
    public static Connection getConnection(){
        Connection connection = null;
        try {
             connection = factory.newConnection();
             return connection;
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }
}
